package br.com.lp3.livraria.controller.clientes;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.lp3.livraria.dao.ClienteDao;
import br.com.lp3.livraria.model.Cliente;

@WebServlet(urlPatterns="/view/clientes/mostrar.do")
public class MostrarClienteServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		Long id = Long.parseLong(req.getParameter("id"));
		
		ClienteDao clienteDao = new ClienteDao();
		Cliente cliente = clienteDao.buscarPorId(id);
		
		req.setAttribute("cliente", cliente);
		RequestDispatcher requestDispatcher = req.getRequestDispatcher("mostrar.jsp");
		requestDispatcher.forward(req, resp);
	}
}
